import {
  BitFieldResolvable,
  Client,
  ClientOptions,
  GatewayIntentsString,
} from 'discord.js';

/** The fucking bot. */
export default class Bot extends Client {
  /** The bot's human-readable name */
  public static botName = 'Bot Base';
  /** The bot's contributors & maintainers */
  public static authors = ['Expo'];
  /** Getter, for returning the authors, in the format of `author, author2, and author3` - WITH A FUCKING OXFORD COMMA */
  public static get authorsAsStr() {
    const authorsArr = [...this.authors];
    const lastAuthor = authorsArr.pop();
    return `${authorsArr.join(', ')}${
      authorsArr.length > 0 ? `, and ${lastAuthor}` : lastAuthor
    }`;
  }
  /** It's a constructor. */
  public constructor(
    options: Partial<ClientOptions> & {
      intents: BitFieldResolvable<GatewayIntentsString, number>;
    },
  ) {
    super({
      ...options,
    });
  }
  /** Gets the bot name. Tries to automatically find it, falling back to the static field */
  public get botName() {
    return Bot.botName.endsWith('Base')
      ? this.user?.displayName ?? Bot.botName
      : Bot.botName;
  }
}
